let app = getApp();

Component({
    data: {
      selected: 0,
    "color": "#2c2c2c",
    "selectedColor": "#fc5157",
    "borderStyle": "white",
    "backgroundColor": "#fff",
      list: []
    },
    attached() {
        if( app.SCOPE_TYPE == 2){
            this.setData({
                list: [
                    {
                        "text": "商城",
                        "pagePath": "pages/index/index",
                        "iconPath": "/images/home_gray.png",
                        "selectedIconPath": "/images/home.png"
                    },
                    {
                        "text": "我的水票",
                        "pagePath": "pages/tabBar/water/water",
                        "iconPath": "/images/ticket.png",
                        "selectedIconPath": "/images/ticket_select.png"
                    },
                    {
                        "text": "购物车",
                        "pagePath": "pages/tabBar/shoppingCart/shoppingCart",
                        "iconPath": "/images/shipping_gray.png",
                        "selectedIconPath": "/images/shipping.png"
                    },
                    {
                        "text": "我的",
                        "pagePath": "pages/tabBar/mine/mine",
                        "iconPath": "/images/member_gray.png",
                        "selectedIconPath": "/images/member.png"
                    }
                ]
              })
        }else{
            this.setData({
                list: [
                    {
                        "text": "商城",
                        "pagePath": "pages/index/index",
                        "iconPath": "/images/home_gray.png",
                        "selectedIconPath": "/images/home.png"
                    },

                    {
                        "text": "购物车",
                        "pagePath": "pages/tabBar/shoppingCart/shoppingCart",
                        "iconPath": "/images/shipping_gray.png",
                        "selectedIconPath": "/images/shipping.png"
                    },
                    {
                        "text": "我的",
                        "pagePath": "pages/tabBar/mine/mine",
                        "iconPath": "/images/member_gray.png",
                        "selectedIconPath": "/images/member.png"
                    }
                ]
              })
        }
        tabbarHeight:app.globalData.tabbarHeight
    },
    ready() {
      const query = wx.createSelectorQuery().in(this);
      query.select('.tab-bar').boundingClientRect((rect) => {
        app.globalData.tabbarHeight = rect.height
      }).exec()
    },
    methods: {
      switchTab(e) {
        let data = e.currentTarget.dataset
        let url = '/' + data.path
        wx.switchTab({url})
        this.setData({
          selected: data.index
        })
      }
    }
  })
